//
// Created by henry on 2025/11/7.
//
#include "front.h"
#include "front_user_menu.h"
//前端入口
int front_entry(){
    printf("欢迎进入前端系统!\n");
    front_menu();
}
int clear_buffer3() {
    int c;
    while ((c = getchar()) != '\n' && c != EOF);
}
//前端菜单
int front_menu(){
    int running =1;
    while (running) {
        printf("===========前端菜单============\n");
        printf("1.用户登陆 2.用户注册 3.返回上级\n");
        printf("请输入选择（1-3）：");
        int choose;
        if (scanf("%d",&choose)!=1||choose<=0){
            printf("请输入有效的数字\n");
            clear_buffer3();
        }
        switch (choose) {
            case 1: {
                int rc = front_user_login();
                if(rc==0){
                    user_entry();
                }
                break;
            }
            case 2:
                front_user_regist();
                break;
            case 3:
                running = 0;
                printf("返回主菜单！\n");
                break;
            default:
                printf("输入错误，请重新输入!\n");
                break;
        }

    }
}